<?php
include("../../lib/db.lib");
include("../../lib/std.lib");

$str = "";

$file_id0 = "/".$_GET["id"];
$file_id = preg_replace("/\//","_",$file_id0);

if(file_exists("./$file_id"))
{
	$fh=fopen("./$file_id","r");
	$str=fread($fh, 200000);
	fclose($fh);
}
else
{
	$fh=fopen("http://www.xys.org/xys/$file_id0","r");
	while(!feof($fh)) $str.=fread($fh, 200000);
	fclose($fh);

	$fh=fopen("./$file_id","w");
	fwrite($fh, $str);
	fclose($fh);

}

/*
$fh=fopen("http://wwwdata.txt","r");
$str=fread($fh, 200000);
fclose($fh);
*/

$str = "<pre>\n".$str."\n</pre>";

$str = iconv("GB2312","UTF-8",$str);

//$str = preg_replace("/([^\n])\n([^\n])/","$1$2",$str);


$str = base64_encode($str);

//echo $str;
//exit(0);

$pass=54;

$newstr = chr($pass);
for($i=0;$i<strlen($str);$i++){
	$newstr.= chr( (ord(substr($str,$i,1)) + $i+1 - 43 +$pass) % 80+43);
}
echo $newstr;

$newstr = "\n ";
for($i=0;$i<strlen($str);$i++){
	$newstr.=  ord(substr($str,$i,1));
	$newstr.=  substr($str,$i,1);
	$newstr .= " ";
}
//echo $newstr;


?>
